import urllib
import urllib2

cookies = urllib2.HTTPCookieProcessor()
opener = urllib2.build_opener(cookies)


data = 'username=herberthb&password=789456'
request = urllib2.Request(
        url     = 'https://passport.baidu.com/?login',
        data    = data)

f = opener.open(request)

print f.info()
f = opener.open('http://hi.baidu.com/herberthb/creat/blog/')
print f.info()
url     = 'http://hi.baidu.com/herberthb/commits'
data = 'ct=1&cm=1&spRefURL=http%3A%2F%2Fhi.baidu.com%2Fherberthb%2Fcreat%2Fblog%2F&spBlogTitle=vvvvvvvvvv&spBlogText=gggggggggggggggggggg&spBlogCatName=%C4%AC%C8%CF%B7%D6%C0%E0&spIsCmtAllow=1&spBlogPower=0&spVcode=&spVerifyKey=&tj=+%B7%A2%B1%ED%CE%C4%D5%C2+'
headers = {
    'Host':'hi.baidu.com',
    'User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1',
    'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
    'Accept-Language':'zh-cn,zh;q=0.5',
    'Accept-Encoding':'gzip,deflate',
    'Accept-Charset':'gb2312,utf-8;q=0.7,*;q=0.7',
    'Keep-Alive':'300',
    'Connection':'keep-alive',
    'Referer':'http://hi.baidu.com/herberthb/creat/blog/',
    'Content-Type':'application/x-www-form-urlencoded',
    }
request1 = urllib2.Request(url,data,headers)

f = opener.open(request1)
print f.info()
